var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataObj:{},
    isHasPrice:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getData()
  },
  goPriceActivity(){
      // if(this.data.dataObj.activity_review_status == 1){
      //   wx.showToast({
      //     title: '审核中...',
      //     icon:'none'
      //   })
      //   return
      // }
      wx.navigateTo({
        url: '/pages/new_doc/priceActivity/index?type=1',
      })
  },
  deletePrice(){
    wx.showModal({
      title:'提示',
      content:"是否确认删除？",
      success:r=>{
        if(r.confirm){
          let url= 'api/shopr/delActivityPrice'
          app.post({
            url:url,
            data:{
              shop_id:wx.getStorageSync('shop_id')
            },
            success:e=>{
              let res = e.data;
              wx.showToast({
                title: res.msg,
                icon:'none'
              })
              if(res.code == 1){
                this.getData()
              }
            }
          })
        }
      }
    })
  },
  getData(){
    let url= 'api/shopr/shopOilInfo'
    app.post({
      url:url,
      data:{
        shop_id:wx.getStorageSync('shop_id')
      },
      success:e=>{
        let res = e.data.data;
        if(JSON.stringify(res.info) == '{}'){
          this.setData({
            isHasPrice:false
          })
        }else{
          let info = res.info;
          // if(info.activity_review_status){
          //   for(let k in info.activity_review){
          //     if(k == 'end_time' || k == 'sale_date' ||k=='sale_type' || k=='start_time'){
          //       info[k] = info.activity_review[k]
          //     }
              
          //   }
          // }
          if(info.sale_type == 1){
            let date = info.sale_date.split(',')
            let day = [];
            for(let i = 0;i < date.length;i++){
              if(date[i] == 0) day.push('周日');
              if(date[i] == 1) day.push('周一');
              if(date[i] == 2) day.push('周二');
              if(date[i] == 3) day.push('周三');
              if(date[i] == 4) day.push('周四');
              if(date[i] == 5) day.push('周五');
              if(date[i] == 6) day.push('周六');
            }
            info.sale_date = day.join('、')
          }
          this.setData({
            dataObj:info,
            isHasPrice:true
          })
        }
        
      }
    })
  }
  
})